package HLCode.ASM;

import HLCode.HLCustomFunction;
import HLCode.ASM.value.ASM_Bool;

public class HLASM_JumpWithCondition extends HLASM_Jump {
    ASM_Bool condition;

    public int Load(byte[] data, int pos) {
        condition = new ASM_Bool();
        pos = condition.Load(data, pos);
        return super.Load(data, pos);
    }

    public void Execute(HLCustomFunction ownerFunction) {
        if (condition.GetValue(ownerFunction)) {
            ownerFunction.curLineIndex++;
        } else {
            ownerFunction.curLineIndex = jumpTo;
        }
    }
}
